package com.itita.ww2.utils.properties;

import org.apache.commons.lang.StringUtils;

import com.itita.ww2.core.ServerService;

/**
 * config.properties Reader.
 * @author NorthLan
 *
 */
public class ServerProperties {

	public static String getString(String key, String defaultValue) {
		String ret = ServerService.getInstance().getConfigValue(key, defaultValue).orElse(null);
		if (StringUtils.isBlank(ret) || ret == null) {
			ret = defaultValue;
		}
		
		return ret;
	}

	public static String getString(String key) {
		return getString(key, "");
	}

	public static int getInt(String key, int defaultValue) {
		return Integer.parseInt(getString(key, String.valueOf(defaultValue)));
	}

	public static int getInt(String key) {
		return getInt(key, 0);
	}

	public static long getLong(String key, long defaultValue) {
		return Long.parseLong(getString(key, String.valueOf(defaultValue)));
	}

	public static long getLong(String key) {
		return getLong(key, 0L);
	}

	public static boolean getBoolean(String key, boolean defaultValue) {
		return Boolean.parseBoolean(getString(key, String.valueOf(defaultValue)));
	}

	public static boolean getBoolean(String key) {
		return getBoolean(key, false);
	}
}
